import { GET, POST, UPLOAD, DOWNLOAD } from "./http";

export const BASE_URL = "/api";

// 登录
export const UserLogin = (data, options) =>
    POST(BASE_URL + "/user/login", { body: data, ...options });

// 注册
export const UserRegister = (data, options) =>
    POST(BASE_URL + "/user/register", { body: data, ...options });

// 获取模板列表
export const GetTemplate = (data, options) =>
    POST(BASE_URL + "/template/get_template", { body: data, ...options });

// 获取用户信息
export const GetUserInfo = (data, options) =>
    POST(BASE_URL + "/user/get_user_info", { body: data, ...options });

// 获取行业分类
export const GetIndustryList = (data, options) =>
    POST(BASE_URL + "/industry/get_list", { body: data, ...options });

// 更新用户信息
export const SetUserInfo = (data, options) =>
    POST(BASE_URL + "/user/set_user_info", { body: data, ...options });

// 获取个人作品
export const GetWorkList = (data, options) =>
    POST(BASE_URL + "/user/get_work_list", { body: data, ...options });

// 获取制作中的作品
export const GetInProduction = (data, options) =>
    POST(BASE_URL + "/template/get_in_production", { body: data, ...options });

// 获取模板分类
export const GetTemplateCategory = (data, options) =>
    POST(BASE_URL + "/template/get_template_category", {
        body: data,
        ...options,
    });

// 获取作品广场
export const GetWorkSquare = (data, options) =>
    POST(BASE_URL + "/user/get_works_square_list", { body: data, ...options });

// 获取vip支付
export const GetVipPay = (data, options) =>
    POST(BASE_URL + "/pay/vip", { body: data, ...options });

// 获取vip价格
export const GetVipPrice = (data, options) =>
    POST(BASE_URL + "/template/get_template_price", { body: data, ...options });

// 检查模版购买状态
export const CheckStatus = (data, options) =>
    POST(BASE_URL + "/pay/check_status", { body: data, ...options });

// 获取模版支付
export const GetTemplatePay = (data, options) =>
    POST(BASE_URL + "/pay/template", { body: data, ...options });

// 获取订单状态
export const GetOrderStatus = (data, options) =>
    POST(BASE_URL + "/pay/get_order_status", { body: data, ...options });

// 删除作品
export const DelWork = (data, options) =>
    POST(BASE_URL + "/user/del_work", { body: data, ...options });

// 删除我的作品
export const DelInProduction = (data, options) =>
    POST(BASE_URL + "/user/del_in_production", { body: data, ...options });

// 点击预览人数
export const SetTemplatePageView = (data, options) =>
    POST(BASE_URL + "/template/page_view", { body: data, ...options });

// 获取模版预览人数
export const GetTemplatePageView = (data, options) =>
    POST(BASE_URL + "/template/get_page_view", { body: data, ...options });

export const SetWorkSquarePageView = (data, options) =>
    POST(BASE_URL + "/user/work_square_page_view", { body: data, ...options });

// 获取作品广场预览人数
export const GetWorkSquarePageView = (data, options) =>
    POST(BASE_URL + "/user/get_work_square_page_view", {
        body: data,
        ...options,
    });

export const GEtTemplateList = (data, options) =>
    POST(BASE_URL + "/template/get_template_list", { body: data, ...options });

// 忘记密码
export const ForgetPwd = (data, options) =>
    POST(BASE_URL + "/user/forget_password", { body: data, ...options });

// 修改密码
export const UpdatePwd = (data, options) =>
    POST(BASE_URL + "/user/change_password", { body: data, ...options });

// 更换手机号
export const ChangePhone = (data, options) =>
    POST(BASE_URL + "/user/change_phone", { body: data, ...options });

// 获取用户会员信息
export const GetVipInfo = (data, options) =>
    POST(BASE_URL + "/pay/get_vip_info", { body: data, ...options });

// 发送验证码
export const SendUserCode = (data, options) =>
    POST(BASE_URL + "/user/code", { body: data, ...options });

// 验证码登录
export const UserLoginByCode = (data, options) =>
    POST(BASE_URL + "/user/mobilelogin", { body: data, ...options });

// 退出登录
export const UserLogout = () => GET(BASE_URL + "/user/loginout");

// 获取用户购买状态
export const GetVipBuyStatus = (data, options) =>
    POST(BASE_URL + "/pay/getVipBuyStatus", { body: data, ...options });

// 获取用户购买状态
export const GetOrderList = (data, options) =>
    POST(BASE_URL + "/pay/getOrderList", { body: data, ...options });

// 获取用户购买状态
export const GetWorkOrderList = (data, options) =>
    POST(BASE_URL + "/pay/getWorkOrderList", { body: data, ...options });

// 获取用户购买状态
export const GetBuyTemplates = (data, options) =>
    POST(BASE_URL + "/pay/getBuyTemplates", { body: data, ...options });

export const GetBuyWorks = (data, options) =>
    POST(BASE_URL + "/pay/getBuyWorks", { body: data, ...options });

// 获取案例列表
export const GetCaseList = (data, options) =>
    POST(BASE_URL + "/examcase/get_examcase", { body: data, ...options });

// 获取案例分类
export const GetCaseCate = (data, options) =>
    POST(BASE_URL + "/examcase/get_examcase_cate", { body: data, ...options });

// 获取案例详情
export const GetCateDetail = (data, options) =>
    POST(BASE_URL + "/examcase/get_examcase_cate_detail", {
        body: data,
        ...options,
    });

// 申请案例体验
export const ApplyCaseExperience = (data, options) =>
    POST(BASE_URL + "/examcase/apply", {
        body: data,
        ...options,
    });

// 获取首页案例
// export const GetHomeCaseList = (data, options) =>
//     POST(BASE_URL + "/index/case", { body: data, ...options });

export const GetHomeCaseList = (data, options) =>
    POST(BASE_URL + "/index/get_new_case", { body: data, ...options });

// 获取首页模版
export const GetHomeTemplateList = (data, options) =>
    POST(BASE_URL + "/index/template", { body: data, ...options });

// 获取首页新闻
export const GetHomeNewsList = (data, options) =>
    POST(BASE_URL + "/index/news", { body: data, ...options });

// 获取首页用户发布作品
export const GetHomeWorksList = (data, options) =>
    POST(BASE_URL + "/index/works", { body: data, ...options });

// 作品点赞
export const WorkLike = (data, options) =>
    POST(BASE_URL + "/index/work_like", { body: data, ...options });

// 作品收藏
export const WorkStar = (data, options) =>
    POST(BASE_URL + "/index/work_star", { body: data, ...options });

// 留言
export const AddUserContact = (data, options) =>
    POST(BASE_URL + "/user/contact", { body: data, ...options });

// 获取新闻列表
export const GetNewsList = (data, options) =>
    GET(BASE_URL + "/news/list", { query: data, ...options });

// 获取新闻详情
export const GetNewsDetail = (data, options) =>
    GET(BASE_URL + "/news/detail", { query: data, ...options });

// 修改头像
export const ChangeAvatar = (data, options) =>
    UPLOAD(BASE_URL + "/user/changeAvatar", { body: data, ...options });

// 获取头像
export const GetAvatar = (data, options) =>
    GET(BASE_URL + "/user/getAvatar", { query: data, ...options });

// 获取token信息
export const GetTokenInfo = () => GET(BASE_URL + "/user/getTokenInfo");

// 获取Banner
export const GetBanner = (data) =>
    POST(BASE_URL + "/index/banner", { body: data });

// 获取VR配置信息
export const GetVrInfo = (data) => GET(BASE_URL + "/index/vr", { query: data });

// 记录勾选免责声明记录
export const PostAgreeLog = (data) =>
    POST(BASE_URL + "/log/agree", { body: data });

// 记录勾选免责声明记录
export const GetContactNum = (data) =>
    GET(BASE_URL + "/index/num", { query: data });

// 作品广场发布评论
export const PostWorksComment = (data) =>
    POST(BASE_URL + "/index/works_comment", { body: data });

export const PostCaseComment = (data) =>
    POST(BASE_URL + "/index/case_comment", { body: data });

// 作品广场分享记录
export const PostWorksShare = (data) =>
    POST(BASE_URL + "/index/works_share", { body: data });

// 作品广场获取分享记录
export const GetWorksShare = (data) =>
    GET(BASE_URL + "/index/get_works_share", { query: data });

// 获取作品广场评论
export const GetWorksCommentList = (data) =>
    GET(BASE_URL + "/index/get_works_comment", { query: data });

export const GetCaseCommentList = (data) =>
    GET(BASE_URL + "/index/get_case_comment", { query: data });

export const GetMidNum = (data) =>
    GET(BASE_URL + "/index/mid_num", { query: data });

export const GetLikeOrStarList = (data) =>
    GET(BASE_URL + "/index/like_or_star_list", { query: data });

export const SetTaskScore = async (data) => {
    const res = await GET(BASE_URL + "/index/set_task_score", { query: data });
    if (res.code == 200) {
        const dialogStore = useDialogStore();
        await GET_MIDNUM();
        dialogStore.isScoreSuccessMsgVisible = true;
        dialogStore.scoreSuccessNum = res.data;
    }
    return res;
};

export const GetScoreTaskList = (data) =>
    GET(BASE_URL + "/index/get_score_task_list", {
        query: data,
    });

export const SetPageView = () => POST(BASE_URL + "/platform/pageview");

export const SetOnline = () => POST(BASE_URL + "/platform/online");

export const SetIp = () => GET(BASE_URL + "/platform/ip");

export const SetVisitor = () => GET(BASE_URL + "/platform/visitor_log");

export const SetExamcaseView = (data) =>
    POST(BASE_URL + "/examcase/examcase_view", { body: data });

export const SetPlatformModuleViews = (data) => {
    if (process.env.NODE_ENV === "production") {
        return POST(BASE_URL + "/platform/moduleviews", { body: data });
    } else {
        return {};
    }
};

export const ExamcaseLike = (data) =>
    POST(BASE_URL + "/index/examcase_like", { body: data });

export const ExamcaseStar = (data) =>
    POST(BASE_URL + "/index/examcase_star", { body: data });

export const SignIn = async (data) => {
    const res = await POST(BASE_URL + "/index/sign_in", { body: data });
    if (res.code == 200) {
        const userStore = useUserStore();
        const dialogStore = useDialogStore();
        GET_MIDNUM();
        dialogStore.isScoreSuccessMsgVisible = true;
        dialogStore.scoreSuccessNum = res.data;
    }
    return res;
};

export const GetScoreLog = (data) =>
    GET(BASE_URL + "/index/get_score_log", { query: data });

export const SignInInfo = (data) =>
    GET(BASE_URL + "/index/sign_in_info", { query: data });

export const GETFriendshipLink = (data) =>
    GET(BASE_URL + "/index/get_friendship_link", { query: data });

export const GetScoreLottery = (data) =>
    GET(BASE_URL + "/index/get_score_lottery", { query: data });

export const SetScoreLottery = (data) =>
    POST(BASE_URL + "/index/set_score_lottery", {
        body: data,
    });

export const GetScoreExchange = (data) =>
    GET(BASE_URL + "/index/get_score_exchange", { query: data });

export const SetScoreExchange = (data) =>
    POST(BASE_URL + "/index/set_score_exchange", { body: data });

export const GetAvatarList = (data) =>
    GET(BASE_URL + "/index/get_avatar_list", {
        query: data,
    });

export const GetScoreExchangeCoupons = (data) =>
    GET(BASE_URL + "/index/get_score_exchange_coupons", {
        query: data,
    });

export const GetMessage = (data) =>
    GET(BASE_URL + "/message/index", {
        query: data,
    });

export const HasNewMessage = (data) =>
    GET(BASE_URL + "/message/has_new", {
        query: data,
    });

export const IsReadMessage = (data) =>
    POST(BASE_URL + "/message/is_read", {
        body: data,
    });

export const GetRandomTemplate = (data) =>
    GET(BASE_URL + "/index/random_template", { query: data });

export const GetRandomWork = (data) =>
    GET(BASE_URL + "/index/random_work", { query: data });

export const GetRandomNews = (data) =>
    GET(BASE_URL + "/index/random_news", { query: data });

export const PostWorksCommentReply = (data) =>
    POST(BASE_URL + "/comment_reply/reply", { body: data });

export const GetWorksCommentReply = (data) =>
    GET(BASE_URL + "/comment_reply/get_reply", { query: data });

export const DelWorksComment = (data) =>
    POST(BASE_URL + "/index/del_works_comment", { body: data });

export const DelCaseComment = (data) =>
    POST(BASE_URL + "/index/del_case_comment", { body: data });

export const GetEditVersion = () => GET(BASE_URL + "/index/get_edit_version");

export const GetWorksSquareTop = (data) =>
    GET(BASE_URL + "/works_square/top", { query: data });

export const GetWorksSquareHot = (data) =>
    GET(BASE_URL + "/works_square/hot", { query: data });

export const GetOtherListApi = (data) =>
    GET(BASE_URL + "/works_square/other", { query: data });

export const GetWorksSquareAcademy = (data) =>
    GET(BASE_URL + "/works_square/academy", { query: data });

export const GetWorksSquareList = (data) =>
    GET(BASE_URL + "/works_square/list", { query: data });

export const GetWorksSquareFamous = (data) =>
    GET(BASE_URL + "/works_square/famous", { query: data });

export const GetHomeLiveSetting = () =>
    GET(BASE_URL + "/index/get_live_setting");

// 修改封面图
export const ChangeWorkCover = (data, options) =>
    UPLOAD(BASE_URL + "/works_square/changeCover", { body: data, ...options });

// 修改作品名称
export const ChangeWorkName = (data, options) =>
    UPLOAD(BASE_URL + "/works_square/changeName", { body: data, ...options });

// 修改作品介绍
export const ChangeWorkIntroduce = (data, options) =>
    UPLOAD(BASE_URL + "/works_square/changeIntroduce", {
        body: data,
        ...options,
    });

export const UpdateWorksInfo = (data, options) => UPLOAD(BASE_URL + "/works_square/updateInfo", {
    body: data,
    ...options,
})

// 初始化登录log
export const initLoginlog = () => POST(BASE_URL + "/user/init_loginlog");

export const GetRecommendCase = (data) =>
    GET(BASE_URL + "/examcase/get_recommend_case", { query: data });

export const GetNoticeTipsStatus = (data) =>
    GET(BASE_URL + "/notice-tips", { query: data });

export const GetTemplateType = (data) =>
    POST(BASE_URL + "/template/get_templates_type", {
        body: data,
    });

export const SearchTemplate = (data) =>
    GET(BASE_URL + "/search/template", { query: data });

export const SearchCase = (data) =>
    GET(BASE_URL + "/search/case", { query: data });

export const SearchNews = (data) =>
    GET(BASE_URL + "/search/news", { query: data });

export const SearchWorks = (data) =>
    GET(BASE_URL + "/search/works", { query: data });

export const GetHomeTemplateCategory = () =>
    GET(BASE_URL + "/index/get_template_category");

export const PostExamcaseShare = (data) =>
    POST(BASE_URL + "/index/examcase_share", {
        body: data,
    });

export const GetAccountStatus = (data) =>
    GET(BASE_URL + "/index/get_account_status", { query: data });

export const GetPersonalPesources = (data) =>
    POST(BASE_URL + "/user/get_personal_pesources", {
        body: data,
    });

export const DelPersonalPesources = (data) =>
    POST(BASE_URL + "/user/del_personal_pesources", {
        body: data,
    });

export const SetPersonalPesources = (data) =>
    POST(BASE_URL + "/user/set_personal_pesources", {
        body: data,
    });

export const DelPersonalModel = (data) =>
    POST(BASE_URL + "/user_model/del", {
        body: data,
    });

export const GetModelList = (data) =>
    POST(BASE_URL + "/user_model/list", {
        body: data,
    });

export const GetMaterialTemplateCategory = (data) =>
    POST(BASE_URL + "/store/get_template_category", {
        body: data,
    });

export const GetMaterialList = (data) =>
    POST(BASE_URL + "/store/list", {
        body: data,
    });

export const GetMaterialDetail = (data) =>
    POST(BASE_URL + "/store/detail", { body: data });

export const UploadAvatar = (data) =>
    UPLOAD(BASE_URL + "/user/upload_avatar", {
        body: data,
    });

export const DownloadFile = (url, options = {}) => DOWNLOAD(url, options);

export const CheckFileSize = (data) =>
    POST(BASE_URL + "/user/check_file_size", {
        body: data,
    });

export const UploadModel = (data) =>
    UPLOAD(BASE_URL + "/user_model/upload", {
        body: data,
    });

export const PostCaseCommentReply = (data) =>
    POST(BASE_URL + "/comment_reply/case_reply", { body: data });

export const GetCaseCommentReply = (data) =>
    GET(BASE_URL + "/comment_reply/get_case_reply", { query: data });

export const CheckWorkAuthority = (data) =>
    GET(BASE_URL + "/pay/check_work_authority", { query: data });

export const GetWorkPay = (data) =>
    POST(BASE_URL + "/pay/work", { body: data });

export const GetCrowdQrcode = (data) =>
    GET(BASE_URL + "/index/get_crowd_qrcode", { query: data });

export const GetStorePay = (data) =>
    POST(BASE_URL + "/pay/store", { body: data });

export const StoreExchange = (data) =>
    POST(BASE_URL + "/pay/store_exchange", { body: data });

export const StoreOrderPay = (data) =>
    POST(BASE_URL + "/pay/store_order_pay", { body: data });

export const TicketOrderPay = (data) => POST(BASE_URL + "/pay/ticket_order_pay", { body: data });

export const StoreFreeExChange = (data) =>
    POST(BASE_URL + "/pay/free_exchange", { body: data });

export const AddCart = (data) => POST(BASE_URL + "/cart/add", { body: data });

export const DelCart = (data) => POST(BASE_URL + "/cart/del", { body: data });

export const GetCartList = (data) =>
    GET(BASE_URL + "/cart/list", { query: data });

export const UserResidenceTime = (data) =>
    POST(BASE_URL + "/user/user_residence_time", { body: data });

export const GetCustomizedPrice = (data) => GET(BASE_URL + "/pay/get_customized_price", { query: data });

export const GetUserWorkList = (data) => GET(BASE_URL + "/works_square/user_list", { query: data });

export const GetUserHomepage = (data) => GET(BASE_URL + "/user/homepage", { query: data });

export const GetMyHomepage = (data) => GET(BASE_URL + "/user/my_homepage", { query: data });

export const GetHomepageDetail = (data) => GET(BASE_URL + "/homepage/detail_list", { query: data });

export const GetUserHomepageDetail = (data) => GET(BASE_URL + "/homepage/user_detail_list", { query: data });

export const Follow = (data) => POST(BASE_URL + "/homepage/follow", { body: data });

export const UnFollow = (data) => POST(BASE_URL + "/homepage/unfollow", { body: data });

export const GetDialogueUserInfo = (data) => GET(BASE_URL + "/dialogue/info", { query: data });

export const SendDialogueMessage = (data) => POST(BASE_URL + "/dialogue/send", { body: data });

export const GetDialogueHistory = (data) => GET(BASE_URL + "/dialogue/history", { query: data });

export const GetMyShareList = (data) => GET(BASE_URL + "/works_square/my_share_list", { query: data });

export const GetMyWorksList = (data) => GET(BASE_URL + "/works_square/my_list", { query: data });

export const GetMyStarList = (data) => GET(BASE_URL + "/works_square/my_star_list", { query: data });

export const GetMyLikeList = (data) => GET(BASE_URL + "/works_square/my_like_list", { query: data });

export const GetUpdateCaseList = (data, options) => POST(BASE_URL + "/index/get_update_case", { body: data, ...options });

export const GetUpdateWorksList = (data, options) => GET(BASE_URL + "/works_square/update_list", { query: data, ...options });

export const GetFirendList = (data) => GET(BASE_URL + "/message/friend_list", { query: data });

export const GetTicketWorksList = (data) => GET(BASE_URL + "/ticket/list", { query: data });

export const GetTicketDetail = (data) => GET(BASE_URL + "/ticket/detail", { query: data });

export const TicketShare = (data) => POST(BASE_URL + "/ticket/share", { body: data });

export const TicketCancelShare = (data) => POST(BASE_URL + "/ticket/cancel_share", { body: data });

export const GetTicketShareInfo = (data) => GET(BASE_URL + "/ticket/share_info", { query: data });

export const TicketReceiveShare = (data) => POST(BASE_URL + "/ticket/receive_share", { body: data });

export const GetKnowledgeVideosList = (data) => GET(BASE_URL + "/knowledge_videos/list", { query: data });

export const GetVersion = () => GET(BASE_URL + "/version");

export const knowledge_page_views = (data) => POST(BASE_URL + "/knowledge_videos/page_view", { body: data });